package com.tgy.myplus.controller;

import com.tgy.myplus.entity.Picture;
import com.tgy.myplus.entity.Student;
import com.tgy.myplus.service.impl.PictureServiceImpl;
import com.yzk18.GUI.GUI;
import com.yzk18.commons.IOHelpers;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class PictureController {
    @Resource
    PictureServiceImpl pictureService;

    @PostMapping("png")
    public int querryAll (){
        //String fileName = GUI.fileOpenBox("666");
        String fileName = "C:\\Users\\tanggy\\Desktop\\实时费用图片\\n0451gyf1462.png";
        System.out.println(fileName);
        byte [] fileByte = IOHelpers.readAllBytes(fileName);
        Picture picture = new Picture();
        picture.setId(2);
        picture.setFilebyte(fileByte);
        picture.setFilename(IOHelpers.getFileName(fileName));
        //System.out.println(Arrays.toString(fileByte));
        int a = this.pictureService.insert(picture);
        return a;
    }

}
